package com.usian.controller;

import com.usian.pojo.SearchItem;
import com.usian.service.SearchItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author chen
 * @date 2021/1/19 - 10:39 - 星期二
 * @project usian_parent
 * @package com.usian.controller
 * @by GGbomd猪猪侠
 */
@RestController
public class SearchItemController {

    @Autowired
    private SearchItemService searchItemService;

    /**
     * 导入商品库到Elasticsearch
     * 操作 tb_item  tb_item_cat  tb_item_desc 表
     * @return
     */
    @RequestMapping("/importAll")
    public Boolean importAll(){
        return searchItemService.importAll();
    }

    /**
     * 首页搜索
     * @param q 搜索条件
     * @param page 第几页
     * @param pageSize  显示几条
     * @return
     */
    @RequestMapping("/list")
    public List<SearchItem> selectByq(String q, Integer page, Integer pageSize){
        return searchItemService.selectByq(q,page,pageSize);
    }
}
